package cn.wolfcode.trip.base.domain;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;

@Getter
@Setter
public class Travel extends BaseDomain {

    public static final int STATE_COMMON = 0; //普通
    public static final int STATE_WAIT = 1; //待发布
    public static final int STATE_RELEASE = 2; //已发布
    public static final int STATE_REJECT = -1; //拒绝

    //标题
    private String title;
    //旅游时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date travelTime;
    //人均消费
    private String perExpends;
    //旅游天数
    private Integer days;
    //参与人物 1.一个人的旅行 2.和父母 3.和朋友 4.和同事 5.和爱人 6.和其他
    private Integer person;
    //作者
    private User author;
    //创建时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
    //发布时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date releaseTime;
    //是否公开
    private Boolean isPublic;
    //旅游地区
    private Region place;
    //封面
    private String coverUrl;
    //最后更新时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date lastUpdateTime;
    //状态
    private int state;
    //游记内容
    private TravelContent travelContent;

    public String getJsonString() {
        HashMap<Object, Object> map = new HashMap();
        map.put("id", id);
        map.put("title", title);
        map.put("coverUrl", coverUrl);
        return JSON.toJSONString(map);
    }
}